package model;

import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

/**
 * Bereitet das HintergrundBild des Status auf
 * 
 * 
 * @date 29.12.2011
 * @author rs
 * @version
 * 
 */
public class BackgroundPanel extends JPanel {
	ImageIcon icon;

	public BackgroundPanel(ImageIcon icon) {
		this.icon = icon;
	}

	protected void paintComponent(Graphics g) {
		super.paintComponent(g);
		if (this.icon != null) {
			g.drawImage(icon.getImage(), 0, 0, this);
		}
	}

	public Dimension getPreferredSize() {
		if (icon != null) {
			return new Dimension(icon.getIconWidth(), icon.getIconHeight());
		} else {
			return super.getPreferredSize();
		}
	}
}